-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Clear CommandCursorResult.results after next()/tryNext(). #1780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…aining consumed batches while cursor stays open. JAVA-5940
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses memory usage optimization by clearing the results list in CommandCursorResult after cursor operations. The change ensures that once results are consumed via next() or tryNext(), the internal results collection is emptied to prevent memory retention.
- Adds a factory method to create CommandCursorResult instances with empty results
- Modifies CommandBatchCursor to clear results after consumption
- Introduces a private constructor for internal use in the factory method
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
CommandCursorResult.java | Adds factory method and private constructor to support creating instances with empty results |
CommandBatchCursor.java | Clears commandCursorResult.results after consuming batch data in doNext() |
driver-core/src/main/com/mongodb/internal/operation/CommandCursorResult.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the AsyncCommandCursor also need this change?
Good point, I’ve added the change for |
JAVA-5940